package operation;

import book.Book;
import book.Booklist;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: wx
 * Date: 2023-11-14
 * Time: 14:47
 */
public class FindOperation implements IOPeration{


    @Override
    public void work(Booklist booklist) {
        System.out.println("*******  查找图书:  *******");

        System.out.println("**** 请输入要查找的图书: ****");
        Scanner scanner = new Scanner(System.in);
        String name = scanner.nextLine();
        //遍历数组
        int currentSize = booklist.getUsedsize();
        for (int i = 0; i < currentSize; i++) {
            Book book = booklist.getbook(i);
            if(book.getName().equals(name)) {
                System.out.println("找到了这本书,信息如下:  ");
                System.out.println(book);
                return;
            }
        }
        System.out.println("没有找到这本书");
    }
}
